<template>
	<view v-if="height > 0" :style="'width: 100%; height: '+height+'px;'">
		<web-view ref="webView" :style="'width: 100%; height: '+height+'px;'" :src="'http://www.ieater.uduemc.com/map/gaode-marker?' + query"></web-view>
	</view>
</template>

<script>
	export default {
		name: "g-map-marker",
		props: {},
		computed: {
			query() {
				return 'width=' + this.width + '&height=' + this.height + '&lng=' + this.marker.lng +
					'&lat=' + this.marker.lat;
			}
		},
		data() {
			return {
				width: 0,
				height: 0,
				top: 0,
				marker: {
					lng: 0,
					lat: 0
				}
			}
		},
		methods: {
			show(wth, hgh, top, marker) {
				this.marker = marker
				this.width = parseInt(wth)
				this.height = parseInt(hgh)
				this.top = parseInt(top)
				this.$nextTick(() => {
					// #ifdef APP-PLUS
					var currentWebview = this.$parent.$scope.$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效，非v3编译模式使用this.$mp.page.$getAppWebview()
					var wv = currentWebview.children()[0]
					wv.setStyle({
						top: this.top,
						height: this.height,
						scalable: false //webview的页面是否可以缩放，双指放大缩小
					})
					// #endif

					// #ifdef H5
					this.$refs.webView.$el.style.top = this.top + "px";
					// #endif
				})
			}
		}
	}
</script>

<style scoped lang="scss">
</style>
